<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>设置我的密码</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">

</head>
<link rel="stylesheet" href="/js/layui/css/layui.css" media="all">
<link rel="stylesheet" href="/css/common.css" media="all">
<script src="/js/layui/layui.js"></script>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">修改密码</div>
                <div class="layui-card-body" pad15>

                    <div class="layui-form" lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户名</label>
                            <div class="layui-input-inline">
                                <input type="text" name="adminName" id="adminName" lay-verify="required" lay-verType="tips"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">旧密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="yuanpassword" id="yuanpassword" lay-verify="pass" lay-verType="tips"
                                       autocomplete="off" id="LAY_password" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password" id="password" lay-verify="repass" lay-verType="tips"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" id="updata" lay-filter="setmypass">确认修改</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/js/layui/layui.all.js"></script>
</body>
</html>
<script>

    var $ = layui.$;
    $("#adminName").val(layui.data("adminName").useradminName);

    $("#updata").click(function () {
        if ($("#yuanpassword").val()=="") {
            layer.msg("请填写原密码", {icon: 2});
            return false;
        }
        if ($("#password").val()=="") {
            layer.msg("请填写新密码", {icon: 2});
            return false;
        }
        $.ajax({
            type: 'post',
            url: '/admin/xiuPassword',
            data: {
                yuanpassword:$("#yuanpassword").val(),
                password:$("#password").val(),
                adminName:$("#adminName").val()
            },
            success: function (res) {
                if (res.code == 200) {
                    layer.msg('修改成功', {
                        icon: 1,
                        time: 1000
                    })
                    setTimeout(function () {
                        top.document.location.href='/index.html';
                    }, 1000)
                    return
                }
                layer.msg(res.msg, {
                    icon: 2
                })
            },
            error: function () {
                layer.msg('网络原因修改失败', {
                    icon: 2
                })
            }
        })


    })



</script>

